package com.jeck.action.cu_loginadmin;

import com.jeck.action.cu_loginadmin.bussiness.Login;
import com.struts.ActionBase;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
/**
 *
 * @author bicho
 */
public class LoginJeck extends ActionBase{
    String user;
    String pass;   
    List menu;

    @Override
    public String execute(){
        if(getUser().isEmpty()){
            addFieldError("user", "Campo no puede ser vacio");
            return INPUT;
        }
        if(getPass().isEmpty()){
            addFieldError("pass", "Campo no puede ser vacio");
            return INPUT;
        }
        Login lg = new Login();
        if(lg.validateAdmin(getUser(), getPass())){
            System.err.println("setteando menu");
            setMenu(lg.getMenu());
            getRequest().getSession().setAttribute("menu", getMenu());
            return SUCCESS;
        }
        
        addActionError("Los datos ingresados son incorrectos");
        return ERROR;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public List getMenu() {
        return menu;
    }

    public void setMenu(List menu) {
        this.menu = menu;
    }

}
